import os
import sys

# 添加项目根目录到Python路径，以便导入config_reader模块
current_dir = os.path.dirname(os.path.abspath(__file__))
project_root = os.path.dirname(os.path.dirname(current_dir))
sys.path.append(project_root)

from config_reader import get_openai_api_key
from openai import OpenAI

# 从配置文件获取API密钥
api_key = get_openai_api_key()

client = OpenAI(
  api_key=api_key
)

response = client.chat.completions.create(
  model="gpt-4o-mini",
  messages=[{
    "role": "user",
    "content": "write a haiku about ai"
  }]
)

print(response.choices[0].message.content)
